#include <iostream>
using namespace std;

//#define DEBUG
//1789
int n, nDist, nIndex;
char code[2002 * 7];
char s[2002];
char maps[2002];

int calcDist(int a, int b) {
	int k, dist;
	char* i;
	char* j;
	if (a == b) 
		return 0;
	else {
		dist = 0;
		i = code + 7 * a;
		j = code + 7 * b;
		for (k = 0; k < 7; k++) {
			if (*i != *j) {
				dist++;
			}
			i++;
			j++;
		}
		return dist;
	}

}

void getNearest() {
	int i, tmpDist;
	nDist = 100;
	nIndex = -1;
	for (i = 1; i < n; i++) {
		if (maps[i] == 0 && s[i] < nDist) {
			nDist = s[i];
			nIndex = i;
		}
	}
	maps[nIndex] = 1;
	for (i = 1; i < n; i++) {
		if (maps[i] == 0) {
			tmpDist = calcDist(nIndex, i);
			if (tmpDist < s[i])
				s[i] = tmpDist;
		}
	}
}

int process() {
	int i;
	int l = 0;
	s[0] = 0;
	maps[0] = 1;
	for (i = 1; i < n; i++) {
		s[i] = calcDist(0, i);
		maps[i] = 0;
	}
	for (i = 0; i < n - 1; i++) {
		getNearest();
		l += nDist;
	}
	return l;
}
int main(int argc, char *argv[])
{
	int i, ans;
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		}
		for (i = 0; i < n ; i++) {
			//scanf("%s", code + i * 7);
			char* p = code + i * 7;
			cin >> p;
		}
		code[7 * n] = '\0';
		ans = process();
		cout << "The highest possible quality is 1/" << ans << "." << endl;
	}
    return 0;
}
